<?php
namespace app\common\model;
use think\Model;
class Ads extends Model{
	// 开启自动写入时间戳字段
	protected $autoWriteTimestamp = true;	
    // 定义时间戳字段名
    protected $createTime = '';
    protected $updateTime = '';	
	// 自动完成
	protected $auto = ['ads_uptime'];
	protected $insert = ['ads_addtime'];
	protected $update = [];
	
    protected function setAdsAddtimeAttr(){
        return time();
    }
    protected function setAdsUptimeAttr(){
        return time();
    }

    public function ad_cache(){
	    $list = db('ads')->order('ads_uptime desc')->select();
	    foreach($list as $key=>$val){
		    zanpian_write_file(ROOT_PATH. DS .config('system.system_adsfile'). DS .$val['ads_name'].'.js',zanpian_tojs(stripslashes(trim($val['ads_content']))));	
	    }
	}	

}
// +----------------------------------------------------------------------
// | ZanPianCMS
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.zanpiancms.com All rights reserved.
// +----------------------------------------------------------------------
// | BBS:  <http://www.zanpiancms.cc>
// +----------------------------------------------------------------------
?>